package gold.digger;

import gold.vo.ListNode;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC206 {
    public long startExecuteTime = System.currentTimeMillis();


    public ListNode reverseList(ListNode head) {
        if (null == head) {
            return null;
        }

        if (null == head.next) {
            return head;
        }

        ListNode reverseTail = head.next;
        ListNode newHead = reverseList(head.next);
        reverseTail.next = head;
        head.next = null;
        return newHead;
    }


    public static void main(String[] args) {
        LC206 an = new LC206();
        ListNode head = ListNode.createList(" 1->2->3->4->5");
        System.out.println(an.reverseList(head));

        System.out.println("\nanswer total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
